<?php
use think\facade\Route;

Route::group('adminapi',function (){
    // 系统设置
    Route::group('system', function () {
        Route::post('menu/getList', 'adminapi.system.menu/getList');//获取菜单管理列表
        Route::post('menu/getMenus', 'adminapi.system.menu/getMenus');//获取菜单列表
        Route::post('menu/getOption', 'adminapi.system.menu/getOption');//获取菜单选择列表
        Route::post('menu/read', 'adminapi.system.menu/read');//获取单条菜单
        Route::post('menu/delete', 'adminapi.system.menu/delete');//删除菜单
        Route::post('menu/create', 'adminapi.system.menu/save'); // 创建
        Route::post('menu/edit', 'adminapi.system.menu/update'); // 更新
        Route::rule("config/:action", 'adminapi.system.config/:action');
    });
    //  附件 相关路由
    Route::group('attachment', function () {
        /**************************************菜单******************************************************/
        //附件管理
        Route::resource("index", 'adminapi.attachment.Attachment');
        Route::resource("group", 'adminapi.attachment.AttachmentGroup');
        //获取列表
        Route::post("list", 'adminapi.attachment.Attachment/list');
        //上传
        Route::post("upload", 'adminapi.attachment.Attachment/upload');
        //移动
        Route::post("move", 'adminapi.attachment.Attachment/move');
        //删除
        Route::post("delete", "adminapi.attachment.Attachment/delete");

        //图片本地化
        Route::get('down', 'adminapi.attachment.Attachment/down');
    });

    /**
     * 用户模块 相关路由
     */
    Route::group('user', function () {
        /**************************************用户相关******************************************************/
        //用户登录
        Route::post('login', 'adminapi.user.user/login');
        //获取用户信息
        Route::post('info', 'adminapi.user.user/info');
        //退出登录
        Route::post('logout', 'adminapi.user.user/logout');
        //获取管理员列表
        Route::post('getList', 'adminapi.user.user/getList');
        //获取编辑表单
        Route::post('getUserForm', 'adminapi.user.user/getUserForm');
        //设置表单内容
        Route::post('setUserForm', 'adminapi.user.user/setUserForm');
        //获取钱包编辑表单
        Route::post('getUserWalletForm', 'adminapi.user.user/getUserWalletForm');
        //设置钱包表单内容
        Route::post('setUserWalletForm', 'adminapi.user.user/setUserWalletForm');
        //删除用户
        Route::post('delete', 'adminapi.user.user/delete');
        //获取权限表单
        Route::post('getUserAddonAuthForm', 'adminapi.user.user/getUserAddonAuthForm');
        //获取权限表单
        Route::post('setUserAddonAuth', 'adminapi.user.user/setUserAddonAuth');
        /**************************************权限相关******************************************************/
        //用户组路由
        Route::resource("UserGroup", "adminapi.user.UserGroup");
        Route::post('UserGroup/getList', 'adminapi.user.UserGroup/index');
        Route::post('UserGroup/getForm', 'adminapi.user.UserGroup/read');
        Route::post('UserGroup/save', 'adminapi.user.UserGroup/save');
        Route::post('UserGroup/update', 'adminapi.user.UserGroup/update');
        Route::post('UserGroup/delete', 'adminapi.user.UserGroup/delete');
        //子账号权限
        Route::rule('UserPermission/:action', 'adminapi.user.UserPermission/:action');
    });

    // 应用组
    Route::group('addonGroup', function () {
        Route::resource("index", 'adminapi.addonAuth.AddonGroup');
        Route::get("getList", "adminapi.addonAuth.AddonGroup/index");
        Route::post("getCreateForm", "adminapi.addonAuth.AddonGroup/create");
        Route::post("getEditForm", "adminapi.addonAuth.AddonGroup/edit");
        Route::post("delete", "adminapi.addonAuth.AddonGroup/delete");
        Route::post("save", "adminapi.addonAuth.AddonGroup/save");//保存
        Route::post("update", "adminapi.addonAuth.AddonGroup/update");//更新
    });
    // 应用组用户权限
    Route::group('addonGroup/user', function () {
        Route::post('setUserAddonAuth', 'adminapi.addonAuth.UserAddonAuth/setUserAddonAuth');
        Route::post('getUserAddonAuthForm', 'adminapi.addonAuth.UserAddonAuth/getUserAddonAuthForm');

    });

    //客户端添加应用
    Route::group('addonGroup/userPlatform', function () {
        Route::post('getUserAddonList', 'adminapi.addonAuth.UserPlatformAddonAuth/getUserAddonList');
        Route::post('getUserAddonList2', 'adminapi.addonAuth.UserPlatformAddonAuth/getUserAddonList2');
        Route::post('getUserAddonAppList', 'adminapi.addonAuth.UserPlatformAddonAuth/getUserAddonAppList');
        Route::post('getUserAddonAppList2', 'adminapi.addonAuth.UserPlatformAddonAuth/getUserAddonAppList2');
    });

    /**
     * 客户端
     */
    Route::group('customer', function () {
        Route::resource("platform", 'adminapi.customer.platform');
        Route::rule("addons/:action", 'adminapi.customer.addons/:action');
    });
    /**
     * 平台
     */
    Route::group('platform', function () {
        /**************************************微信公众平台******************************************************/

        Route::group('wechat', function () {

            Route::resource("index", 'adminapi.platform.wechat.Wechat');
            Route::rule('index/:action', 'adminapi.platform.wechat.Wechat/:action');
            //用户
            Route::resource('user', 'adminapi.platform.wechat.WechatUser');
            //退款
            Route::resource('refund', 'adminapi.platform.wechat.WechatRefund');
            //付款
            Route::resource('transfer', 'adminapi.platform.wechat.WechatTransfer');
            //订单
            Route::resource('order', 'adminapi.platform.wechat.WechatOrder');
            //分账
            Route::resource('share', 'adminapi.platform.wechat.WechatShare');
            Route::rule('share/:action', 'adminapi.platform.wechat.WechatShare/:action');
            //分账账户
            Route::resource('share_receiver', 'adminapi.platform.wechat.WechatShareReceiver');
            //应用
            Route::rule('addon/:action', 'adminapi.platform.wechat.WechatAddon/:action');
            //设置
            Route::rule('setting/:name', 'adminapi.platform.wechat.WechatSetting/:name');
        });
        // 小程序平台
        Route::group('min_app', function () {
            Route::resource("index", 'adminapi.platform.app.MinApp');
            // 小程序通用
            Route::rule('index/:action', 'adminapi.platform.app.MinApp/:action');
            // 小程序设置
            Route::rule('setting/:action', 'adminapi.platform.app.MinAppSetting/:action');
            // 小程序上传
            Route::rule('upload/:action', 'adminapi.platform.app.MinAppUpload/:action');
            // 服务商
            Route::rule('open/:action', 'adminapi.platform.app.MinAppOpen/:action');
            // 抖音服务商
            Route::rule('douyin_open/:action', 'adminapi.platform.app.MinAppDouyinOpen/:action');
        });
        // 自由平台
        Route::group('free', function () {
            Route::resource("index", 'adminapi.platform.free.free');
            Route::rule('index/:action', 'adminapi.platform.free.free/:action');
            //设置
            Route::rule('setting/:name', 'adminapi.platform.free.FreeSetting/:name');
        });
        // 企业微信平台
        Route::group('work_wechat', function () {
            Route::resource("index", 'adminapi.platform.work_wechat.WorkWechat');
            Route::rule('index/:action', 'adminapi.platform.work_wechat.WorkWechat/:action');
            Route::rule('addon/:action', 'adminapi.platform.work_wechat.WorkWechatAddon/:action');
            Route::rule('apps/:action', 'adminapi.platform.work_wechat.WorkWechatApps/:action');
            Route::rule('kf/msg/:action', 'adminapi.platform.work_wechat.WorkWechatKfMsg/:action');
            Route::rule('kf/user/:action', 'adminapi.platform.work_wechat.WorkWechatKfUser/:action');
            Route::rule('kf/servicer/:action', 'adminapi.platform.work_wechat.WorkWechatKfServicer/:action');
            //设置
            Route::rule('setting/:name', 'adminapi.platform.work_wechat.WorkWechatSetting/:name');
        });
        // 抖音平台
        Route::group('douyin', function () {
            Route::resource("index", 'adminapi.platform.douyin.Douyin');
            Route::rule('index/:action', 'adminapi.platform.douyin.Douyin/:action');
            Route::rule('addon/:action', 'adminapi.platform.douyin.DouyinAddon/:action');
            //设置
            Route::rule('setting/:name', 'adminapi.platform.douyin.DouyinSetting/:name');
        });
        Route::resource("index", 'adminapi.platform.index');
        // 通用平台
        Route::rule('addon/:action', 'adminapi.platform.PlatformAddon/:action');
        // 小程序平台
        Route::rule('app/:action','adminapi.platform.PlatformApp/:action');
        // 小程序用户次数
        Route::rule('app_user/:action','adminapi.platform.PlatformAppUser/:action');
        //修改状态
        Route::post('status', 'adminapi.platform.index/status');
        //删除平台
        Route::post('delete', 'adminapi.platform.index/delete');
        //清除平台
        Route::post('destroy', 'adminapi.platform.index/destroy');
        //恢复平台
        Route::post('recovery', 'adminapi.platform.index/recovery');
        Route::rule('editUserForm', 'adminapi.platform.index/editUserForm');
        Route::rule('saveUser', 'adminapi.platform.index/saveUser');
    });
    Route::rule("diy/:action",'adminapi.diy.diy/:action');
    Route::rule("addon_diy/:action",'adminapi.diy.addon_diy/:action');
    Route::rule("cloud_diy/:action",'adminapi.diy.cloud_diy/:action');
    Route::rule("cloud/:action", 'adminapi.cloud.cloud/:action');
    // 外部请求当前系统同步数据
    Route::rule("cloud_local/:action", 'adminapi.cloud.local/:action');
    // 默认
    Route::rule('', 'adminapi.index/index');//默认为index
    Route::rule(':controller/:action', 'adminapi.:controller/:action');//其他方法
    Route::rule(':controller', 'adminapi.:controller/index');//默认为index
});

